﻿using System;
using System.Globalization;

namespace Bule.Malbilden.Util
{
    public class InputFilter
    {
        // Checks if s can be converted to a numeric value if c is appended to s.
        public static bool GivesValidNumeric(Char c, string s)
        {
            bool isValid = false;

            string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            bool isSeparator = (c.ToString() == separator);
            bool containsSeparator = s.Contains(separator);

            if (isSeparator && !containsSeparator)
                isValid = true;
            else if (Char.IsDigit(c) || Char.IsControl(c))
                isValid = true;

            return isValid;
        }
    }
}
